Part Number Hot Search : 
MBD20 BD380 P6KE16CA KBPC2506 AC1007S P6KE13 124096 2J224K
Product Description
Full Text Search
 

To Download AN214 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  ? 2000 microchip technology inc. preliminary ds00214a-page 1 AN214 introduction this application note discusses the organization of the picmicro mcu and related firmware for developing ieee 1451.2 smart transducer interface modules (stim). although a detailed understanding of the 1451.2 is not required, a working knowledge of 1451.2 concepts like transducer electronic data sheet (teds), stims, data models, etc., is assumed. the purpose of this application note is to provide the devel- opers of a picmicro mcu based stim with some key hardware and firmware building blocks, that may be uti- lized in the development of a stim. ieee-1451.2 overview the ieee 1451 standard is composed of four parts, 1451.1, 1451.2, 1451.3 and 1451.4. the combination of the four parts (some parts are approved and others are pending) define the signal chain from the analog sensor to the digital network (see figure 1). the main objectives of the ieee 1451 standard are to: ? enable plug and play at the transducer level (sensor or actuator) by providing a common com- munication interface for transducers.  enable and simplify the creation of networked smart transducers.  facilitate the support of multiple networks. the focus of this application note deals with the 1451.2 part of the standard. the ieee 1451.2 standard provides the means to con- nect sensors and actuators to a digital system, typically a network, via a network capable application proces- sor (ncap). figure 2 depicts a general distributed measurement and control application and figure 3 depicts the functional boundaries relating to the trans- ducer interface standard, namely ieee 1451.2. in simplest terms, the ieee-1451.2 standard does the following:  defines a digital interface for connecting trans- ducers to microprocessors.  describes a teds, ?electronic data sheet?, and its data formats.  defines an electrical interface, read and write logic functions to access the teds, and a wide variety of transducers. this standard does not specify signal conditioning, sig- nal conversion, or how the teds data is used in appli- cations. there is currently no defined independent digital com- munication interface between transducers and micro- processors. each vendor builds its own interface. without an independent, openly defined interface, transducer interfacing and integration are time con- suming and duplicated efforts by vendors are econom- ically unproductive. this interface provides a minimum implementation subset that allows self-identification and configuration of sensors and actuators, and also allows extensibility by vendors to provide growth and product differentiation. authors: richard l. fischer microchip technology inc. jeff burch agilent technologies the picmicro ? mcu as an ieee 1451.2 compatible smart transducer interface module (stim) http://www..net/ datasheet pdf - http://www..net/
AN214 ds00214a-page 2 preliminary ? 2000 microchip technology inc. figure 1: ieee 1451 defines the signal chain from analog sensor to digital network figure 2: general distributed measurement and control application network capable application processor (ncap) smart transducer interface module (stim) meta-teds channel interface module (cim) teds channel- mixed-mode transducer (mmt) teds transducer- network p1451.1 object-model network communications 1451.2 transducer independent interface (tii) p1451.3 channel interface bus (cib) p1451.4 mixed-mode transducer interface (mmti) interface smart sensor node smart sensor node smart actuator node smart actuator node other network gateway computer control network pressure temperature valve solenoid real world process http://www..net/ datasheet pdf - http://www..net/
? 2000 microchip technology inc. preliminary ds00214a-page 3 AN214 what is an ncap? a stim works in conjunction with a microprocessor based interface to a communication network. this module, termed a network capable application pro- cessor (ncap) in the standard, primarily mediates between the stim (whose interface is computer net- work independent) and a particular network. the ncap may also perform correction of the raw data from the stim and may include application specific data processing and control functionality (see figure 3 and figure 4 ). the hewlett-packard bfoot-66501 embedded ether- net controller is the ncap for this application. the con- troller is a complete thin web server solution for manufacturers of smart sensors and actuators, or for manufacturers of products with embedded control who need a way to rapidly create smart ethernet-ready devices that can scale to complete solutions. the bfoot-66501 supports tcp/ip, ftp and http protocols. figure 3: context for the transducer interface specification smart transducer interface module (stim) xdcr xdcr xdcr xdcr adc dac di/o ? transducer electronic data sheet (teds) address logic ncap transducer independent interface (tii) functional boundaries network correction engine network interface application processing network interface http://www..net/ datasheet pdf - http://www..net/
AN214 ds00214a-page 4 preliminary ? 2000 microchip technology inc. figure 4: block diagrams for a general smart transducer and a 1451.2 compatible transducer transducer signal conditioning signal conversion microprocessor network transceiver control network transducer signal conditioning signal conversion microprocessor network transceiver 1451.2 logic teds 1451.2 adds: teds digital interface din dout dclk nioe ntrig nack nint nsdet +5v common 1451.2 digital interface stim fig. 4a fig. 4b control network ncap ncap 10 http://www..net/ datasheet pdf - http://www..net/
? 2000 microchip technology inc. preliminary ds00214a-page 5 AN214 what is a stim? the ieee 1451.2 standard introduces the concept of the stim. a stim can range in complexity from a sin- gle sensor or actuator, to many channels (up to 255 channels) of transducers (sensors or actuators). exam- ples of stim ? s are shown in figure 5 . a transducer channel is denoted "smart" in this context because of the following three features:  it is described by a machine-readable transducer electronic data sheet (teds).  the control and data associated with the channel are digital.  triggering, status, and control are provided to support the proper functioning of the channel. a stim contains the teds, logic to implement the transducer interface, the transducer(s) and any signal conversion or signal conditioning. a stim is controlled by a ncap module by means of a dedicated digital interface. this interface is not a network. the ncap mediates between the stim and a digital network, and may provide local intelligence. it is desirable that the stim and ncap add little size or cost to the trans- ducer(s) they describe and interface. teds memory requirements are typically less than two kilobytes. these size and cost considerations also restrict the computing power available in the ncap. figure 5: examples of 1451.2 smart transducer interface modules microcontroller adc teds temperature sensor stim 1451.2 5a) temperature sensor stim microcontroller teds stim 1451.2 5b) eight channel digital i/o stim in out microcontroller teds stim 1451.2 5c) four channel sensor stim adc temperature sensor pressure sensor flow sensor ph sensor microcontroller teds stim 1451.2 5d) sensor and actuator stim adc temperature sensor pressure sensor proportional valve relay dac digital http://www..net/ datasheet pdf - http://www..net/
AN214 ds00214a-page 6 preliminary ? 2000 microchip technology inc. stim implementation the microchip pic16c62a and 93c86 eeprom are the hardware base for the stim in this application note. other picmicro devices could have been implemented for the stim, such as the pic16c773 with a 93c86. another alternative might be to utilize a microchip spi tm protocol based eeprom device in place of the microwire ? memory device. when developing a stim, there are several parts that must be addressed: - stim hardware - ncap interface - creating the teds - organization of the source code - creating the source code using the te m p l a t e stim hardware the stim hardware must be capable of supporting the 1451.2 interface, the transducer(s) interface and the teds interface (see figure 6 ). these three require- ments should be considered when selecting a pic- micro device for the stim. for example, the 1451.2 interface requires 8 pins (plus power and ground), the teds interface may require up to 4 pins and the trans- ducer interface will most likely require all remaining pins and possibly more. the 1451.2 interface requires a synchronous data transfer with the respective control signals. selecting a picmicro mcu with a spi periph- eral will meet this interface requirement. the trans- ducer interface will vary, depending upon the stim functional requirements. for example, if the stim requires an adc, what are the requirements:  8- 10- or 12-bit adc?  what is the sample rate required?  can the adc on a picmicro mcu be utilized?  is an external stand-alone adc required, e.g., the microchip mcp3201. these are questions which the stim developer must answer. if the stim requires a 12-bit adc, then the pic16c771 or pic16c773 may be a solution. like- wise, if the stim requires a 10-bit adc, then you might use the pic16c717 or flash pic16f873 and elimi- nate the external eeprom. remember that a stim can support up to 255 transducer channels. this stim capability alone may dictate the selection of the picmicro device for the stim. finally, the teds interface must be evaluated. the size of the teds will, for the most part, depend on the number of transducer channels that the stim supports. the teds is read, written and used by the ncap. the teds holds information, such as: sensitivity, serial number, model number, date of last calibration, specific model number data characteristics, etc. if the stim mcu is otp based, then an external eeprom device is required. if the stim mcu is flash based, such as the pic16f873, then no external eeprom is required, since you may use the flash program memory for the teds. figure 6: stim interface block diagram 1451.2 interface pic16c62a teds eeprom transducer interface 93c86 pin 1: cs pin 2: clk pin 3: di/in pin 4: do/out custom rc3/sck rc4/sdi rc5/sdo rc7 v ss /dgnd ra5/ss rc6 rc2 v dd rb4 rb1 rb2 rb3 ra0-4 rb0, rb5-7 rc0-1 pin 1: dclk pin 2: din pin 3: dout pin 4: nack pin 5: dcom pin 6: nioe pin 7: nint pin 8: ntrig pin 9: +5 v pin 10: nsdet (tie to dcom) http://www..net/ datasheet pdf - http://www..net/
? 2000 microchip technology inc. preliminary ds00214a-page 7 AN214 ncap interface the physical connection between the ncap and the pic16c62a (stim) is a 10-pin transducer indepen- dent interface (tii) (see figure 6 ). the tii is built around a synchronous serial communications based on the serial peripheral interface (spi) protocol. the recommended tii pin assignments are listed in table 1, which also indicates whether each physical signal is considered an input or output by the ncap and the stim. the tii logical signal definitions and functions are shown in tab l e 2 , which also indicates whether a signal is positive or negative logic and whether it is level or edge sensitive. the ssp module of the pic16c62a is used for spi communications between the ncap and stim. when developing the teds, one parameter to consider is the maximum data rate for spi transfers. the respective picmicro mcu specification should also be considered for this teds entry. the 1451.2 interface provides for the sequence of reading and writing between the ncap and the stim. the top level protocols are read frame, write frame and triggering. the general data transfer protocol is shown in figure 7. in addition to the logical signals described above, the tii also supplies power and a common ground refer- ence to the stim. the ncap supplies up to 75 ma at 5v 0.20v dc to the stim. the standard provides for supplemental power, independent of the ncap, if needed for sensitive or high-power transducers, but only the ncap can provide power for the stim inter- face control circuitry. finally, the connector type is left up to the developer of the stim. the ieee-1451.2 standard does not call out a connector type. however, the standard does recom- mend that the stim connector be:  at least ten pins  male (because the stim will not supply power)  polarized for this stim implementation, a 2x5 polarized connec- tor is implemented. table 1: recommended tii pin assignments table 2: tii signal definition pin number signal name wire color direction for ncap direction for stim 1 dclk brown out in 2dinredout in 3 dout orange in out 4nack yellow in out 5 common (ground) green power power 6nioe blue out in 7nint violet in out 8ntrig gray out in 9power (5 v dc ) white power power 10 nsdet black in out line logic driven by function din positive logic ncap transports address and data from ncap to stim dout positive logic stim transports data from stim to ncap dclk positive edge ncap positive-going edge latches data on both din and dout nioe active low ncap signals that the data transport is active and delimits data transport framing ntrig negative edge ncap performs triggering function nack negative edge stim serves two functions: 1. trigger acknowledge 2. data transport acknowledge nint negative edge stim used by the stim to request service from the ncap nsdet active low stim used by the ncap to detect the presence of a stim power n/a ncap nominal 5v power supply common n/a ncap signal common or ground http://www..net/ datasheet pdf - http://www..net/
AN214 ds00214a-page 8 preliminary ? 2000 microchip technology inc. figure 7: general data transfer protocol read read sensor write write actuator read frame trigger read frame write frame write frame trigger http://www..net/ datasheet pdf - http://www..net/
? 2000 microchip technology inc. preliminary ds00214a-page 9 AN214 creating the transducer electronic data sheet (teds) creating the teds is recommended before you start firmware development. through this process, you will have sufficient information to develop the custom trans- ducer interface firmware. the key decisions that must be made are outlined below:  define how many channels will be provided by the stim  define the data type for each channel (e.g., sensor, actuator, event sensor, etc.)  define the data model for each channel (e.g., integer, float, doubles, etc.)  define which channels (if any) have data repetitions it is recommended to use a teds editor when creating the actual teds. a template teds is provided as part of this application note (stimtemp.ted). usually, you will load it into the editor and make appropriate modifica- tions. the template teds (stimtemp.ted) specifies a two-channel loopback stim. this is illustrated in figure 8 . if desired, you can initially set each channel to cal_none to disable the correction process. this will save you some time, because you will not need to specify the correction model. later, after your stim is functional, you may edit the teds file to provide this information. channel 1 is a 16-bit actuator and channel 2 is a 16-bit sensor. when the device is triggered, the cached actu- ator value is copied to the sensor data buffer. the actu- ator has a ? divide by 10 ? and the sensor has a ? multiply by 10 ? correction. with the conversion from float to unsigned short integer (uint16), the following loopback transformation occurs: 1) write channel 1 with 123.4; 2) read 120 from channel 2. the intervening steps are as follows: 1. 123.4 gets converted to 12.34 by the correction engine. 2. the value is truncated to 12 before being written to the stim channel 1. 3. reading channel 2 receives 12 from the stim. 4. this value is converted to 120.00 by the correc- tion engine. figure 8: loopback stim block diagram ncap stim 1451.2 trigger write 123.4 to ch 1 engine write to ch 1 value with trigger, copy ch1 value to ch2 value read 12 from ch 2 value convert from uint 16 to float convert from float to uint 16 correction divide by 10 correction engine multiply by 10 read 120.0 from ch 2 http://www..net/ datasheet pdf - http://www..net/
AN214 ds00214a-page 10 preliminary ? 2000 microchip technology inc. teds timing parameters the timing parameters in the template teds (stimtemp.ted) are appropriate for a pic16c62a oper- ating at 10 mhz. the key timing parameters are provided in ta bl e 3 below. note that the stimtemp.c has very little ? real ? work to do. consequently, these values are about as fast as is practical, given for a picmicro mcu running at 10 mhz. of course, a picmicro mcu operating at 20 mhz and hand-crafted assembly will yield additional time savings. figure 9 presents a typical timing sequence for a triggered channel 0 read. table 3: stim timing parameters 1451.2 section description value meta teds 5.1.3.17 worst case channel warm-up time 1 msec. 5.1.3.18 command response time ( maximum time to process any command) 100 sec. 5.1.3.19 stim handshake time (time to remove trigger acknowledge) 10 sec. 5.1.3.20 end-of-frame detection latency (maximum time between 1451.2 transactions) 50 sec. 5.1.3.21 teds hold-off time 1.2 msec 5.1.3.22 operational hold-off time 50 sec. 5.1.3.23 maximum data rate 5 mbps channel teds 5.2.3.21 channel update time (maximum time to acknowledge a trigger) 6 sec. 5.2.3.22 channel write setup time (time between end of write frame and application of trigger) 15 sec. 5.2.3.23 channel read setup time (time between trigger back and start of read frame) 160 sec. 5.2.3.24 channel sampling period (minimum time between back-to-back triggers) 160 sec. 5.2.3.25 channel warm-up time 1 msec 5.2.3.26 channel aggregate hold-off time (the total time for the data transport frame at maximum data rate. this includes byte-pacing delays added by the stim) 75 sec. 5.2.3.27 timing correction (correction of timestamp for a given channel with channel 0 trigger) 1 sec. 5.2.3.28 trigger accuracy (accuracy of timing correction) 1 sec. http://www..net/ datasheet pdf - http://www..net/
? 2000 microchip technology inc. preliminary ds00214a-page 11 AN214 figure 9: triggered channel zero read figure 9 represents a 1451.2 bus data transport during a triggered channel 0 read. note that six bytes are transferred across the 1451.2 bus for this transaction (i.e., function address of 128, channel of 0, msb of channel 1, lsb of channel 1, msb of channel 2 and lsb of channel 2). in this measurement, the logic ana- lyzer trigger signal condition was the stim acknowl- edgment of the ncap trigger (first falling edge of the nack signal). various points of interest are identified on the figure and discussed below. 1. channel update time. 2. stim handshake time. 3. channel read setup time. the ncap will wait this long before dropping nioe to begin the read data transaction. in the stimtemp.c implementa- tion, the ncap delay gives the stim time to per- form any status updates and interrupt processing. in a stim with measurement hard- ware, this time would most likely be dominated by adc conversion delays. 4. the increased delay between the end of the channel selector byte and the transmission of the first byte of the data frame. this delay hap- pens when the picmicro device is processing the function code and dispatching to the transducer_read() function. 5. this is the 8 dclk edges that clock the transfer of a single byte across the 1451.2 interface. in the stim, the dclk rate is 5mbps. 6. this is the time for the picmicro device to per- form the byte-handshake. 7. the channel 0 read operation is longer than the channel aggregate hold-off time. 1 2 3 4 5 6 7 http://www..net/ datasheet pdf - http://www..net/
AN214 ds00214a-page 12 preliminary ? 2000 microchip technology inc. organization of the source code the source code is divided into the following files. all files are in a common subdirectory, unless noted. table 4 lists the source code files and provides a brief functional description. the source code files are pro- vided in appendix a. the ram and program memory requirements for this stim implementation are shown in figure 10 . table 4: source code files file name file destination description stimmain.c picmicro mcu this is the main event processing loop for the firmware. you should not need to modify this file. stim.h picmicro mcu global stim variable definitions and function prototypes. you should not need to modify this file. stimdot2.c picmicro mcu this source file provides the functions to manage the 1451.2 communica- tions. you should not need to modify this file. stimdot2.h picmicro mcu variable references and macros utilized for 1451.2 communications and process support. you should not need to modify this file. stimteds.c picmicro mcu this source file provides functions to manage communication with the teds eeprom and reading or writing teds blocks. no modification of this file is required unless you change the memory type for the teds. stimteds.h picmicro mcu reference linkage for variables and functions and picmicro mcu pin defi- nitions for communicating with teds. no modification of this file is required unless you change the memory type for the teds. stimtemp.c picmicro mcu this is a source code template that you will modify for your stim. typically, this is the only file you will need to study. make a copy of this file and rename as appropriate. stimtemp.h picmicro mcu reference linkage for variables and functions for the template.c file. you should not need to modify this file. stiminit.c picmicro mcu this source file provides functions to manage the picmicro mcu initiali- zation. depending on the stim configuration, this file may require modifications. stiminit.h picmicro mcu picmicro mcu port and tris definitions. depending on the stim configuration, this file may require modifications. stimcmd.c picmicro mcu this file is used to process the functional and channel address commands issued by the ncap over the 1451.2 interface. the functions called are located in the stimtemp.c, stimteds.c and stimdot2.c files. you should not need to modify this file. stimcmd.h picmicro mcu reference linkage for variables and functions. pic.h picmicro mcu picmicro mcu processor definition file. this is a hi-tech specific file. no modification of this file is required. common.h picmicro mcu common information for all source files, including 1451.2 interface pin definitions. cnfig62a.h picmicro mcu picmicro mcu configuration bit definition file. you should not need to modify this file. generateversion.cpp pc source code for the pc or hpux tool to generate the stim version string. generateversion pc hpux executable. generateversion.exe pc win32 executable. note: the picmicro mcu based source files were built with the hi-tech picc compiler tool, version 7.85. http://www..net/ datasheet pdf - http://www..net/
? 2000 microchip technology inc. preliminary ds00214a-page 13 AN214 figure 10: program memory usage for stimtemp creating the source code using the template create a new source code module using the supplied template (stimtemp.c). it is recommended that you first copy stimtemp.c to some new file (e.g. mystim.c). per- form the following steps (also outlined in stimtemp.c): 1. define the maximum number of channels on the stim with the #define max_num_channels macro. this is used to allocate memory for the status, mask, aux_status and aux_mask regis- ters. this macro is located in the common.h file. 2. run the ? generateversion ? executable (on either the hpux or win32) and provide a single com- mand line parameter for your stim. for exam- ple: generateversion mystim_v1.0. copy and paste the output into your source file. for this stim, the output is copied into the stimtemp.c file. 3. if your stim hardware uses different pins than those shown in figure 6 , modify the #define statements to override the pin assignments. for the 1451.2 interface pin definitions, see the common.h file. for the teds interface pin defi- nitions, see the stimteds.h file. 4. provide the #defines for the tri-state configura- tion and initial port values (e.g. tris_a_val and init_a_val). since this is done on a byte basis (rather than bit), careful attention should be paid to not alter the values for the 1451.2 or teds eeprom pins. the default values are presented in the stiminit.h file. a value of ? 1 ? in the tri-state register will set the corresponding pin to an input. 5. if you need to override any default processing in the generic code, define the appropriate macro. for example, to implement a non-supported 1451.2 function for a channel 0 operation, pro- vide the following declaration and macro (see table 5 ). note that most parameters are avail- able as global parameters and are therefore, not passed as arguments: 6. declare the following functions: - void transducer_initialize( void ); - void transducer_trigger( void ); - void transducer_read( unsigned char chnl ); - void transducer_write( unsigned char chnl ); 7. implement the above functions: - transducer_initialize( ) - set up the trans- ducer to its reset condition. this function will be called immediately following the con- figuration of the tri-state registers. - transducer_trigger( ) - perform the 1451.2 trigger function. the trig_chnl_addr global variable holds the current trigger address. normally, the standard_trigger( ) function can be called at the end of this function, to per- form the 1451.2 trigger handshake operation. - transducer_read( ) - send data to the ncap by performing the 1451.2 read operation. the chnl_addr global variable holds the current channel address. be prepared to generate a 1451.2 channel 0 read frame, if requested. the chnl_addr will be zero in this case. the wr_1451_byte( ) function should be used to send data to the 1451.2 bus. - transducer_write( ) - receive data from the ncap by performing the 1451.2 write opera- tion. the chnl_addr global variable holds the current channel address. be prepared to receive a 1451.2 channel 0 write frame if requested. the chnl_addr will be zero in this case. the rd_1451_byte( ) function should be used to read each data byte from the 1451.2 bus. free space 34% stimdot2 29% stimteds 23% stimcmd 6% stimtemp 4% stimmain 3% stiminit 1% ram usage - 58 bytes http://www..net/ datasheet pdf - http://www..net/
AN214 ds00214a-page 14 preliminary ? 2000 microchip technology inc. table 5: macros to modify standard stim processing managing status, mask and interrupts by default, this code provides full support for stim sta- tus, interrupt mask, auxiliary status and auxiliary inter- rupt mask registers (function code 130, 132, 133 and 134). this is provided at both the global and channel levels. because the auxiliary registers are optional, a simple mechanism is provided to disable their implementation. just define no_aux_status_registers, which is located in the common.h file. this decreases ram and rom usage. for example, ram decreases by 4*numchannels + 2 for the auxiliary status and mask registers. the stim will generate an interrupt as illustrated in fig- ures 10 and 11 of the 1451.2 standard. note that for each channel, the auxiliary status can generate inter- rupts through two different paths: 1) through the auxil- iary interrupt mask, and 2) through the auxiliary status bit in the channel status register, when combined with that channel ? s interrupt mask. similarly, each channel can generate an interrupt through two paths: 1) through its service request bit, and 2) through the stim ? s global status register and the global interrupt mask. macro name function default value default_1451dot2_function default processing for 1451.2 function codes. post_inval_cmd( ) default_1451dot2_command default processing for 1451.2 commands. post_inval_cmd( ) reset_1451dot2_command perform the reset function for a 1451.2 channel or stim. standard_reset( ) after_1451dot2_frame after processing the payload portion of the transport. note: the frame may still be active if the ncap is trying to read too many bytes. for test purposes only. after_process_teds_prolog after processing the teds header. for test purposes only. check_write_protect check if the teds is write protected. if true, this macro should invoke post_inval_cmd() and return. http://www..net/ datasheet pdf - http://www..net/
? 2000 microchip technology inc. preliminary ds00214a-page 15 AN214 structure of the teds eeprom data the following table describes the eeprom header used by the current code. the actual data blocks follow the 1451.2 standard. table 6: structure of the teds eeprom data teds structure address (hex) length (bytes) field comment file header 0 2 little endian: address of directory, currently 8 2 2 little endian: number of channels (n) 4 2 little endian: teds image format version number, currently 1 6 2 little endian: number of teds blocks per channel, currently 4 begin directory 8 2 little endian: address of meta-teds 10 2 little endian: address of meta-id-teds 12 2 little endian: address of ch 1 channel teds 14 2 little endian: address of ch 1 channel id teds 16 2 little endian: address of ch 1 calibration teds 18 2 little endian: address of ch 1 calibration id teds 20 2 little endian: address of ch 2 channel teds 22 2 little endian: address of ch 2 channel id teds 24 2 little endian: address of ch 2 calibration teds 26 2 little endian: address of ch 2 calibration id teds i(= 8n+4) 2 little endian: address of ch n channel teds i+2 2 little endian: address of ch n channel id teds i+4 2 little endian: address of ch n calibration teds i+6 2 little endian: address of ch n calibration id teds begin teds data j(= i+8) 1 functional address of first teds block j+1 1 channel address of first teds block j+2 4 first teds block length header (long int whose value is l) j+6 l first teds block plus checksum k(= j+6+l) 1 functional address of second teds block k+1 1 channel address of second teds block k+2 4 second teds block length header (long int whose value is m) k+6 m second teds block plus checksum p 1 functional address of last teds block p+1 1 channel address of last teds block p+2 4 last teds block length header (long int whose value is q) p+6 q last teds block plus checksum p+6+q 2 two null bytes note 1: numbers in the file header and pointers in the directory block are 16-bit unsigned little-endian. multiple-byte teds data fields are big-endian. 2: the teds blocks are as defined in ieee 1451.2 draft 3.02. 3: each teds block is preceded by two bytes giving the functional address and the channel address by which the block is addressed in the stim. this identifies the block in the same semantics as the standard and does not depend on absolute address. 4: the pointers in the directory point to the beginning of the block structure, not to the functional/channel address header. (the last entry in the directory is an exception to this in that it is defined to point to a functional address.) 5: the functional/channel address headers provide an alternate way of finding the teds block needed. the first two bytes following the last directory entry are the functional and channel address for the first teds block. if this block is not the one desired, read the next four bytes as a long integer (which is the length of the teds block) and add it to the current read pointer to get the address of the next functional/channel address header. in this way, you can step through memory until you find the teds you want. the null bytes after the last teds blocks signal the end of the linked list. 6: the linked list format allows the addition of other teds and teds extensions. these will not have pointers in the directory and will have to be addressed by walking through the linked list. since these are likely to be less fre- quently accessed, the added time required to do this is of less consequence. http://www..net/ datasheet pdf - http://www..net/
AN214 ds00214a-page 16 preliminary ? 2000 microchip technology inc. limitations in the current implementation the current code has the following limitations: 1. the teds writing mechanism uses the function code 32 and only excepts a write of the full teds file.it does not support writing individual teds blocks (except the channel cal teds). 2. the write cal id teds mechanism is not sup- ported. currently, it returns post_inval_cmd( ). summary the goal of the ieee 1451.2 standard is to provide an industry standard interface to efficiently connect trans- ducers to microcontrollers and to connect microcontrol- lers to networks. microchip technology offers a large portfolio of smart microcontrollers that can be imple- mented as the stim for compliance with the ieee 1451.2 standard. reference material ieee std 1451.2-1997, ieee standard for a smart transducer interface for sensors and actuators - transducer to microprocessor communication proto- cols and transducer electronic data sheet (teds) format pic16c6x data sheet, microchip technology inc., document # ds30234 pic16c717/770/771 data sheet, microchip technol- ogy inc., document # ds41120 pic16c77x data sheet, microchip technology inc., document # ds30275 pic16f87x data sheet, microchip technology inc., document # ds30292, 1998 picmicro tm mid-range mcu family reference man- ual, microchip technology inc., document # ds33023 note: information contained in the application note regarding device applications and the like, is intended for suggestion only and may be superseded by updates. no repre- sentation or warranty is given and no liabil- ity is assumed by microchip technology incorporated, with respect to the accuracy or use of such information, or infringement of patents, or other intellectual property rights arising from such use or otherwise. http://www..net/ datasheet pdf - http://www..net/
? 2000 microchip technology inc. preliminary ds00214a-page 17 AN214 software license agreement the software supplied herewith by microchip technology incorporated (the ? company ? ) for its picmicro ? microcontroller is intended and supplied to you, the company ? s customer, for use solely and exclusively on microchip picmicro microcontroller prod- ucts. the software is owned by the company and/or its supplier, and is protected under applicable copyright laws. all rights are rese rved. any use in violation of the foregoing restrictions may subject the user to criminal sanctions under applicable laws, as well as to civil liability for the breach of the terms and conditions of this license. this software is provided in an ? as is ? condition. no warranties, whether express, implied or statu- tory, including, but not limited to, implied warranties of merchantability and fitness for a particu- lar purpose apply to this software. the company shall not, in any circumstances, be liable for special, incidental or consequential damages, for any reason whatsoever. appendix a: stim source code files /********************************************************************* * * * the picmicro as an ieee 1451.2 compatible smart * * transducer interface module (stim) * * * ********************************************************************** * * * filename: stimmain.c * * date: 06/27/2000 * * revision: 1.12 * * * * contributor: richard l. fischer * * company: microchip technology inc. * * * * contributor: jeff burch * * company: agilent technologies * * * * * * tools: hi-tech pic c compiler v7.85 * * mplab 5.00.00 * * * ********************************************************************** * * * system files required: * * * * stimmain.c * * stimdot2.c * * stiminit.c * * stimteds.c * * stimcmd.c * * stimtemp.c * * * * * * pic.h (hi-tech file) * * common.h * * stim.h * * stimdot2.h * * stiminit.h * * stimteds.h * * stimcmd.h * * cnfig62a.h * * delays.h (hi-tech file) * * * ********************************************************************** * * * notes: * * * * device fosc -> 10.00mhz external crystal * * wdt -> off * * brownout -> on * http://www..net/ datasheet pdf - http://www..net/
AN214 ds00214a-page 18 preliminary ? 2000 microchip technology inc. * powerup timer -> on * * code protect -> off * * * * interrupt sources -> none (at this moment) * * * * * *********************************************************************/ #include // processor if/def file #include ?cnfig62a.h? // configuration word definitions #include ?common.h? // project commons, etc. #include ?stim.h? // __config ( conblank & boden_on & pwrte_on & cp_off & wdt_off & hs_osc ); /******************************************************************************/ void main( void ) { init_pic_ports(); // set port directions, initialize output values transducer_initialize(); // initialize the transducer process_teds_prolog(); // read the teds prolog init_mask_registers( ); // initialize the stim to generate all interrupts init_int_registers( ); // initialize the status registers update_nint(); // on status or mask write update nint aborted_1451_io = 0 ; // initialize global variable for ( ; ; ) { nack_pin = 1; // set nack output to idle high // ensure de-assertion of nioe unless abort noted in prev. frame // espec. important for 2nd, subseq. passes thru this loop // if aborted_1451_io (in prev. frame), do *not* wait for nioe high init_spi( !aborted_1451_io ); // initialize spi module (section 6.3.8) aborted_1451_io = 0 ; // reset variable wrnackdone = 0; // reset variable while ( nioe_pin ) // await assertion of nioe (*ss) from ncap { if ( !ntrig_pin ) // test if ncap is asserting ntrig to stim { transducer_trigger(); // when trigger asserted, call the user?s function } } // at this point the ncap has asserted nioe (*ss) to stim. this signals that the // data transport is active and delimits the transport framing // read the 1451.2 functional and channel address // note if nioe (*ss) is de-asserted, abort the rest of frame func_addr = rd_1451_byte(); // read the 1451.2 functional address if ( aborted_1451_io ) // if global is true continue; // start the for loop again chnl_addr = rd_1451_byte(); // read the 1451.2 channel address if ( aborted_1451_io ) // if global is true continue ; // start the for loop again http://www..net/ datasheet pdf - http://www..net/
? 2000 microchip technology inc. preliminary ds00214a-page 19 AN214 if ( chnl_addr > num_channels ) // test for valid channel address { post_inval_cmd(); // bad channel address, update status } else // valid channel address so ... { process_valid_cmd(); // process functional and channel address } } } http://www..net/ datasheet pdf - http://www..net/
AN214 ds00214a-page 20 preliminary ? 2000 microchip technology inc. /********************************************************************* * * * filename: stim.h * * date: 06/27/2000 * * revision: 1.4 * * * * tools: hi-tech pic c compiler v7.85 * * mplab 5.00.00 * * * * * * description: global stim data and function prototypes * * * *********************************************************************/ extern voidprocess_valid_cmd(); // ======= functions and data from stiminit.c ======= extern void init_pic_ports( void ); extern void init_spi( uchar await_nioe ); // ======= functions and data from stimteds.c ======= // eeprom i/o functions extern void send_ee_bits( uchar databits, uchar bitcount ); // utility for next 3-4 uchar ee_read( unsigned int addr ); // returns status, data is via eeprom_data uchar ee_write( unsigned int addr ); // returns status, data is via eeprom_data uchar ee_wr_enable( uchar opcode ); // should receive: ee_ewen_op or ee_ewds_op // standard teds reads void process_teds_prolog(); // init e.g. teds_format_vsn, teds_blks_per_chnl void rd_meta_teds( void ); void rd_meta_id_teds( void ); void rd_channel_teds( void ); void rd_channel_id_teds( void ); void rd_calibration_teds( void ); void rd_calibration_id_teds( void ); // extension read(s) void rd_fw_version( void ); void rd_full_teds_eeprom( void ); // teds write function(s) void wr_calibration_teds( void ); void wr_calibration_id_teds( void ); void wr_full_teds_eeprom( void ); // eeprom globals uchar eeprom_data; // data for read/write ops. uchar ee_rd_wr_bit_cntr; unsigned int teds_addr; unsigned int teds_addr2; // stim-dependent teds image metadata; these are primed from e^2 ? prolog ? uchar num_channels; uchar teds_format_vsn; uchar teds_blks_per_chnl; ucharwrnackdone;// write nack control http://www..net/ datasheet pdf - http://www..net/
? 2000 microchip technology inc. preliminary ds00214a-page 21 AN214 // ======= functions and data from stimtemp.c ======= extern void transducer_initialize( void ); extern void transducer_trigger( void ); extern void transducer_read( void ); extern void transducer_write( void ); // ======= functions and data from stimdot2.c ======= // 1451 byte i/o functions extern uchar rd_1451_byte( void ); extern uchar wr_1451_byte( uchar abyte ); extern void frame_complete( void ); extern uchar frame_aborted( void ); // tests nioe and aborted_1451_io; sets latter struct events { unsigned int time_expire :1; unsigned int :7; } flag; // 1451 transducer, global functions void rd_status( void ); void rd_aux_status( void ); void rd_trig_chnl_addr( void ); void wr_trig_chnl_addr( void ); void rd_int_mask( void ); void wr_int_mask( void ); void rd_aux_int_mask( void ); void wr_aux_int_mask( void ); void wr_ctrl_cmd( void ); void post_inval_cmd( void ); void update_nint( void ); void standard_trigger( void ); void standard_reset( void ); void init_mask_registers( void ); void init_int_registers( void ); // 1451.2 driver globals uchar func_addr; uchar chnl_addr; uchar trig_chnl_addr = 1; // side-channel status for parties interested in 1451 frame/byte i/o aborts uchar aborted_1451_io; // --- status registers --- // splitting bytes is probably safest (given compilers), easiest, tightest uchar global_status_lo = 0; uchar global_status_hi = 0; uchar chan_status_lo[ max_num_channels ]; uchar chan_status_hi[ max_num_channels ]; // --- interrupt mask registers --- uchar global_int_mask_lo; uchar global_int_mask_hi; uchar chan_int_mask_lo[ max_num_channels ]; http://www..net/ datasheet pdf - http://www..net/
AN214 ds00214a-page 22 preliminary ? 2000 microchip technology inc. uchar chan_int_mask_hi[ max_num_channels ]; // note: the aux status registers and mask are optional. // by default, they are implemented. define the no_aux_status_registers // to disable this implementation #ifndef no_aux_status_registers // --- aux status registers --- uchar global_aux_status_lo = 0; uchar global_aux_status_hi = 0; uchar chan_aux_status_lo[ max_num_channels ]; uchar chan_aux_status_hi[ max_num_channels ]; // --- aux interrupt mask registers --- uchar global_aux_int_mask_lo; uchar global_aux_int_mask_hi; uchar chan_aux_int_mask_lo[ max_num_channels ]; uchar chan_aux_int_mask_hi[ max_num_channels ]; #endif http://www..net/ datasheet pdf - http://www..net/
? 2000 microchip technology inc. preliminary ds00214a-page 23 AN214 /********************************************************************* * * * filename: common.h * * date: 06/27/2000 * * revision: 1.4 * * * * tools: hi-tech pic c compiler v7.85 * * mplab 5.00.00 * * * * * * description: common information for all source files, * * including 1451.2 pin definitions. * * * *********************************************************************/ typedef unsigned char uchar; // create new type #define max_num_channels 2 //#define no_aux_status_registers // set these macros to handle additional global or channel control commands #ifndef default_1451dot2_command #define default_1451dot2_command post_inval_cmd(); #endif #ifndef reset_1451dot2_command #define reset_1451dot2_command standard_reset( ); #endif #ifndef default_1451dot2_function #define default_1451dot2_function post_inval_cmd(); #endif #define nop() asm ( ? nop ? ); /********************************************************************/ // 1451.2 / nsp physical lines #ifndef dclk_pin #define dclk_pin rc3 /* pin 1 of 1451.2 10 pin */ #endif #ifndef din_pin #define din_pin rc4 /* pin 2 */ #endif #ifndef dout_pin #define dout_pin rc5 /* pin 3 */ #endif #ifndef nack_pin #define nack_pin rc7 /* pin 4 */ #endif #ifndef nioe_pin #define nioe_pin ra5 /* pin 6 */ #endif #ifndef nint_pin http://www..net/ datasheet pdf - http://www..net/
AN214 ds00214a-page 24 preliminary ? 2000 microchip technology inc. #define nint_pin rc6 /* pin 7 */ #endif #ifndef ntrig_pin #define ntrig_pin rc2 /* pin 8 */ #endif http://www..net/ datasheet pdf - http://www..net/
? 2000 microchip technology inc. preliminary ds00214a-page 25 AN214 /********************************************************************* * * * filename: cnfig62a.h * * date: 06/27/2000 * * file version: 1.00 * * * * compiler: hi-tech pic c compiler v7.85 * * * *********************************************************************/ /*****configuration bit definitions for pic16c62a picmicro *****/ #define conblank 0x3fff #define boden_on 0x3fff #define boden_off 0x3fbf #define cp_all 0x00cf #define cp_75 0x15df #define cp_50 0x2aef #define cp_off 0x3fff #define pwrte_off 0x3fff #define pwrte_on 0x3ff7 #define wdt_on 0x3fff #define wdt_off 0x3ffb #define lp_osc 0x3ffc #define xt_osc 0x3ffd #define hs_osc 0x3ffe #define rc_osc 0x3fff http://www..net/ datasheet pdf - http://www..net/
AN214 ds00214a-page 26 preliminary ? 2000 microchip technology inc. /********************************************************************* * * * the picmicro as an ieee 1451.2 compatible smart * * transducer interface module (stim) * * * ********************************************************************** * * * filename: stimdot2.c * * date: 06/27/2000 * * revision: 1.8 * * * * contributor: richard l. fischer * * company: microchip technology inc. * * * * contributor: jeff burch * * company: agilent technologies * * * * * * tools: hi-tech pic c compiler v7.85 * * mplab 5.00.00 * * * ********************************************************************** * * * files required: * * * * stimdot2.c * * * * * * pic.h (hi-tech file) * * common.h * * stimdot2.h * * * ********************************************************************** * * * notes: * * * * description: common stim functions for 1451.2 communication * * * *********************************************************************/ #include // processor if/def file #include ? common.h ? #include ? stimdot2.h ? void update_nint( void ); void post_inval_cmd( void ); ////////////////////////////////////////////////////////////////// // reading/writing functions (global) ////////////////////////////////////////////////////////////////// // read a byte from the ncap uchar rd_1451_byte( void ) { uchar result; // temp holding register for sspbuf // nioe is low/asserted on entry; spi is quiescent; sspif is clear // global affected: aborted_1451_io; see description in header file // ensure frame alive; if not, exit w/o issuing nack edge if ( aborted_1451_io ) // if global is true return ( 0x00 ); // return http://www..net/ datasheet pdf - http://www..net/
? 2000 microchip technology inc. preliminary ds00214a-page 27 AN214 // tell the ncap that we are ready to read this byte. // do pacing handshake - enable flow of exactly one byte nack_pin ^= 1; // toggle nack to ncap for ( ; ; ) // loop til frame done or byte received { // global conveys which occurred if ( nioe_pin ) // test if *ss pin negated, frame done? { if ( sspif ) // if spi event true as well ... break; // addresses a race; frame did finish else // if spi event false then.. { aborted_1451_io = 1; // set global to true, indicates abort break; // exit for loop } } if ( sspif ) // if spi event true break; // exit for loop } // unload spi buffer - good or not result = sspbuf; // temp save of sspbuf contents sspif = 0; // clear hardware event interrupt flag sspbuf = 0x00; // set sspbuf to known contents return ( result ); // return with byte read from spi } // write a byte to the ncap uchar wr_1451_byte( uchar abyte ) { // nioe is low/asserted on entry; spi is quiescent; sspif is clear // global affected: aborted_1451_io ; see descr above // ensure frame alive; if not, exit w/o issuing nack edge if ( aborted_1451_io ) // if global is true return ( 0x00 ); // loop til previous frame done or byte done; global conveys which occurred if ( wrnackdone ) // { for ( ; ; ) { if ( nioe_pin ) // test if *ss pin negated, frame done? { if ( sspif ) // if spi event true break; // addresses a race; frame did finish else // if spi event false then.. { aborted_1451_io = 1; // set global to true, indicates abort break; // exit for loop } } if ( sspif ) // if spi event true break; // exit for loop } } // load outbound byte sspbuf = abyte; // load byte for ncap to read sspif = 0; // clear hardware event interrupt flag // do pacing handshake - enable flow of exactly one byte nack_pin ^= 1; // toggle nack to ncap http://www..net/ datasheet pdf - http://www..net/
AN214 ds00214a-page 28 preliminary ? 2000 microchip technology inc. wrnackdone = 1; // return ( 0x00 ); } // test to see if the ncap is aborting the 1451.2 transaction. // check nioe and set the aborted_1451_io global uchar frame_aborted( void ) { // check for nioe deassertion, now or earlier in this frame if ( nioe_pin ) // is nioe (*ss) negated ( by ncap ) aborted_1451_io = 1; // capture observance of frame abort return ( aborted_1451_io ); // return with condition } // return the stim ? s status to the ncap (high byte then low byte) void rd_status( void ) { if ( chnl_addr ) // channels 1-255 status { wr_1451_byte( chan_status_hi[ chnl_addr-1 ] ); // check for nioe (*ss) deassertion, now or earlier this frame if ( aborted_1451_io ) // if global is true return; wr_1451_byte( chan_status_lo[ chnl_addr-1 ] ); // clear bits after seen chan_status_lo[ chnl_addr-1 ] = 0x00; chan_status_hi[ chnl_addr-1 ] = status_operational; // clear bits after seen, leave opera- tional } else // else stim global status { wr_1451_byte( global_status_hi ); // check for nioe (*ss) deassertion, now or earlier this frame if ( aborted_1451_io ) // if global is true return; wr_1451_byte( global_status_lo ); // clear bits after seen global_status_lo = 0x00; // clear bits after seen. note: update_nint( ) will change this. global_status_hi = status_operational; // clear bits after seen, leave operational } update_nint(); // on status or mask write update nint } // return the stim ? s auxiliary status to the ncap void rd_aux_status( void ) { #ifdef no_aux_status_registers post_inval_cmd( ); // call post_inval_cmd( ) #else if ( chnl_addr ) // channels 1-255 auxiliary status { wr_1451_byte( chan_aux_status_hi[ chnl_addr-1 ] ); // check for nioe (*ss) deassertion, now or earlier this frame if ( aborted_1451_io ) // if global is true http://www..net/ datasheet pdf - http://www..net/
? 2000 microchip technology inc. preliminary ds00214a-page 29 AN214 return; wr_1451_byte( chan_aux_status_lo[ chnl_addr-1 ] ); // clear bits after seen chan_aux_status_hi[ chnl_addr-1 ] = 0x00; chan_aux_status_hi[ chnl_addr-1 ] = 0x00; } else // else stim global auxiliary status { wr_1451_byte( global_aux_status_hi ); // check for nioe (*ss) deassertion, now or earlier this frame if ( aborted_1451_io ) // if global is true return; wr_1451_byte(global_aux_status_lo); // clear bits after seen. note: update_nint( ) will change this. global_aux_status_lo = 0x00; global_aux_status_hi = 0x00; } update_nint(); // on status or mask write update nint #endif } // return the trigger channel to the ncap void rd_trig_chnl_addr( void ) { wr_1451_byte( trig_chnl_addr ); } // set the trigger channel. check is performed to prevent setting the trigger address > than // the number of valid channels. void wr_trig_chnl_addr() { uchar old_addr; old_addr = trig_chnl_addr; // save off current trigger channel trig_chnl_addr = rd_1451_byte(); // read in new trigger channel if ( trig_chnl_addr > num_channels ) // test if new trigger is out of range { trig_chnl_addr = old_addr ; // if so, restore trigger channel post_inval_cmd(); // set stim invalid command bit } } // return the stim firmware version. the global vsn_string is accessed. // note that this variable is in rom. (access little slower then ram, but saves ram) void rd_fw_version( void ) { unsigned uchar idx ; for ( idx=0; idx AN214 ds00214a-page 30 preliminary ? 2000 microchip technology inc. } // initialize the stim mask and auxiliary mask registers. default power-up // value for standard int mask register is all ones and all zeros for // auxiliary int mask registers. void init_mask_registers( void ) { uchar ch; for ( ch=0; ch ? 2000 microchip technology inc. preliminary ds00214a-page 31 AN214 // return the auxiliary interrupt mask to the ncap void rd_aux_int_mask( void ) { #ifdef no_aux_status_registers post_inval_cmd( ); // call post_inval_cmd( ) #else if ( chnl_addr ) // channels 1-255 aux. int mask { wr_1451_byte( chan_aux_int_mask_hi[ chnl_addr-1 ] ); // check for nioe (*ss) deassertion, now or earlier this frame if ( aborted_1451_io ) // if global is true return; wr_1451_byte( chan_aux_int_mask_lo[ chnl_addr-1 ] ); } else // else stim global aux. int mask { wr_1451_byte( global_aux_int_mask_hi ); // check for nioe (*ss) deassertion, now or earlier this frame if ( aborted_1451_io ) // if global is true return; wr_1451_byte( global_aux_int_mask_lo ); } #endif } // set the interrupt mask per ncap command void wr_int_mask( void ) { if ( chnl_addr ) // channels 1-255 int mask { chan_int_mask_hi[ chnl_addr-1 ] = rd_1451_byte(); // check for nioe (*ss) deassertion, now or earlier this frame if ( aborted_1451_io ) // if global is true return; chan_int_mask_lo[ chnl_addr-1 ] = rd_1451_byte(); } else // else stim global int mask { global_int_mask_hi = rd_1451_byte(); // check for nioe (*ss) deassertion, now or earlier this frame if ( aborted_1451_io ) // if global is true return; global_int_mask_lo = rd_1451_byte(); } update_nint(); // on status or mask write update nint // maybe better (tho ? slower) to update_nint at frame end } // set the interrupt mask via ncap void wr_aux_int_mask( void ) { #ifdef no_aux_status_registers post_inval_cmd( ); #else if ( chnl_addr ) // channels 1-255 aux. int mask { chan_aux_int_mask_hi[ chnl_addr-1 ] = rd_1451_byte(); // check for nioe (*ss) deassertion, now or earlier this frame http://www..net/ datasheet pdf - http://www..net/
AN214 ds00214a-page 32 preliminary ? 2000 microchip technology inc. if ( aborted_1451_io ) // if global is true return; chan_aux_int_mask_lo[ chnl_addr-1 ] = rd_1451_byte(); } else // else stim global aux. int mask { global_aux_int_mask_hi = rd_1451_byte(); // check for nioe (*ss) deassertion, now or earlier this frame if ( aborted_1451_io ) // if global is true return; global_aux_int_mask_lo = rd_1451_byte(); } update_nint(); // on status or mask write update nint // maybe better (tho ? slower) to update_nint at frame end #endif } // process global commands (see specification secton 4.7) void wr_ctrl_cmd( void ) { uchar cmd_lo, cmd_hi ; cmd_hi = rd_1451_byte(); // read command low byte // check for nioe deassertion, now or earlier this frame if ( aborted_1451_io ) // if global is true return; cmd_lo = rd_1451_byte(); // read command high byte if ( cmd_hi ) { default_1451dot2_command // commands > 255 not implemented at this time } // call post_inval_cmd( ) else { switch ( cmd_lo ) { case command_nop: // ? no operation ? command (value 0) break; case command_reset: // reset stim command (value 1) reset_1451dot2_command // call standard_reset( ); break; default: // else unimplmented command default_1451dot2_command // call post_inval_cmd( ) break; } } } // post an invalid command void post_inval_cmd( void ) { global_status_lo |= status_invalid_command;// set stim invalid command bit update_nint(); } // update nint depending on status and auxiliary status registers void update_nint( void ) { uchar ch, start, stop; http://www..net/ datasheet pdf - http://www..net/
? 2000 microchip technology inc. preliminary ds00214a-page 33 AN214 uchar tmp; if ( chnl_addr ) // if channel 1-255 { start = chnl_addr-1; stop = chnl_addr; } else // else, global channel 0 { start = 0x00; stop = num_channels; // maxmium channels on stim } // we must walk through each channel to update the status bit for that channel #ifdef no_aux_status_registers // with no aux status registers, we must make sure this bit is clear chan_status_lo[ ch ] &= ~status_aux_status; #else /* test if there are any auxiliary status bits set for a specific channel. if true then set the respective channel aux. status available bit. if false then clear the respective channel aux. status available bit. */ for ( ch=start; ch AN214 ds00214a-page 34 preliminary ? 2000 microchip technology inc. #endif // caution: because we are doing an ? or ? , we must loop through each channel for ( ch=0; ch ? 2000 microchip technology inc. preliminary ds00214a-page 35 AN214 // if ncap asserts trig forever, we stick here // should we wait here forever? (suggestion to use timer0 for loop break out) while( !ntrig_pin ); // wait until trigger is negated by ncap nack_pin = 1; // negate the acknowledge signal to ncap // update the trigger acknowledge bit // we do this after the trigger has been acknowledged if ( chnl_addr ) // if channel 1-255 { start = chnl_addr-1; stop = chnl_addr; } else // else, global channel 0 { start = 0x00; stop = num_channels; } for ( ch=start; ch AN214 ds00214a-page 36 preliminary ? 2000 microchip technology inc. // note: spec says.. a stim or channel reset command shall not // affect the value of the interrupt mask bits. update_nint(); } http://www..net/ datasheet pdf - http://www..net/
? 2000 microchip technology inc. preliminary ds00214a-page 37 AN214 /********************************************************************* * * * filename: stimdot2.h * * date: 06/27/2000 * * revision: 1.4 * * * * tools: hi-tech pic c compiler v7.85 * * mplab 5.00.00 * * * * * * * * description: variable references and macros utilized for * * 1451.2 communications and process support. * * * *********************************************************************/ void standard_reset( void ); extern uchar frame_aborted(void); extern struct events { unsigned int time_expire :1; unsigned int :7; } flag; extern uchar aborted_1451_io; extern uchar wrnackdone; // write nack control extern uchar chnl_addr; extern uchar chan_status_hi[ max_num_channels ]; extern uchar chan_status_lo[ max_num_channels ]; extern uchar global_status_lo; extern uchar global_status_hi; extern uchar chan_aux_status_lo[ max_num_channels ]; extern uchar chan_aux_status_hi[ max_num_channels ]; extern uchar global_aux_status_lo; extern uchar global_aux_status_hi; extern uchar trig_chnl_addr; extern uchar num_channels; extern const uchar vsn_string[4 + 0x13 ]; extern uchar chan_int_mask_lo[ max_num_channels ]; extern uchar chan_int_mask_hi[ max_num_channels ]; extern uchar chan_aux_int_mask_lo[ max_num_channels ]; extern uchar chan_aux_int_mask_hi[ max_num_channels ]; extern uchar global_int_mask_lo; extern uchar global_int_mask_hi; extern uchar global_aux_int_mask_lo; extern uchar global_aux_int_mask_hi; /*****************************************************************************/ // 1451.2 functional addresses #define write_transducer_data 0 http://www..net/ datasheet pdf - http://www..net/
AN214 ds00214a-page 38 preliminary ? 2000 microchip technology inc. #define write_control_cmd 1 #define write_triggered_channel_addr 3 #define write_int_mask 5 #define write_aux_int_mask 6 #define write_calibration_teds 64 #define write_calibration_id_teds 65 #define read_transducer_data 128 #define read_status 130 #define read_triggered_channel_addr 131 #define read_aux_status 132 #define read_int_mask 133 #define read_aux_int_mask 134 #define read_fw_version 135 #define read_teds 160 #define read_id_teds 161 #define read_calibration_teds 192 #define read_calibration_id_teds 193 #define write_app_specific_teds 96 #define read_app_specific_teds 224 #define write_full_teds_eeprom 32 #define read_full_teds_eeprom 240 /*****************************************************************************/ // 1451.2 status bits (a 16 bit quantity) is stored in two 8-bit bytes for efficiency // lo byte #define status_service_request 0x01 #define status_trigger_acknowledge 0x02 #define status_reset 0x04 #define status_invalid_command 0x08 #define status_aux_status 0x10 #define status_missed_data 0x20 #define status_data_available 0x40 #define status_hardware_error 0x80 // hi byte #define status_operational 0x01 // 1451.2 interrupt bits, low byte #define int_msk_service_request 0x01 #define int_msk_trigger_acknowledge 0x02 #define int_msk_reset 0x04 #define int_msk_invalid_command 0x08 #define int_msk_aux_status 0x10 #define int_msk_missed_data 0x20 #define int_msk_data_available 0x40 #define int_msk_hardware_error 0x80 // 1451.2 interrupt bits, high byte #define int_msk_operational 0x01 // 1451.2 commands #define command_nop 0x00 #define command_reset 0x01 #define command_initiate_self_test 0x02 #define command_calibrate_channels 0x03 #define command_zero_all_channels 0x04 #define command_enable_event_sequence 0x05 #define command_disable_event_sequence 0x06 #define command_config_event_sequence 0x07 #define command_enable_data_sequence 0x09 #define command_disable_data_sequence 0x0a http://www..net/ datasheet pdf - http://www..net/
? 2000 microchip technology inc. preliminary ds00214a-page 39 AN214 /********************************************************************* * * * the picmicro as an ieee 1451.2 compatible smart * * transducer interface module (stim) * * * ********************************************************************** * * * filename: stiminit.c * * date: 06/27/2000 * * revision: 1.2 * * * * * * contributor: richard l. fischer * * company: microchip technology inc. * * * * contributor: jeff burch * * company: agilent technologies * * * * * * tools: hi-tech pic c compiler v7.85 * * mplab 5.00.00 * * * ********************************************************************** * * * files required: * * * * stiminit.c * * * * pic.h (hi-tech file) * * common.h * * stiminit.h * * * ********************************************************************** * * * notes: * * * * description: common stim functions to initialize the picmicro * * * * port a: a5 input nioe (ss, active low) * * a4 n/c * * a3 n/c * * a2 n/c * * a1 n/c * * a0 n/c * * * * port b: b7 n/c * * b6 n/c * * b5 n/c * * b4 output eepcs initial value = 0 * * b3 input eepdout * * b2 output eepdin initial value = 0 * * b1 output eepdclk initial value = 0 * * b0 n/c * * * * port c: c7 output nack initial value = 1 * * c6 output nint initial value = 1 * * c5 output dout initial value = 0 * * c4 input din * * c3 input dclk (idle high) * * c2 input ntrig (active low) * * c1 n/c * * c0 n/c * * * *********************************************************************/ #include // processor if/def file http://www..net/ datasheet pdf - http://www..net/
AN214 ds00214a-page 40 preliminary ? 2000 microchip technology inc. #include ? common.h ? #include ? stiminit.h ? ////////////////////////////////////////////////////////////////// // picmicro initialization ////////////////////////////////////////////////////////////////// // initialize the h/w spi port void init_spi( uchar await_nioe ) { sspcon = 0b00010100; // set: ckp & spi slave w/nioe (*ss) sspbuf = 0; // set sspbuf to known state sspif = 0; // reset h/w event interrupt flag wrnackdone = 0; // reset global if ( await_nioe ) // test if requiring to test pin { while ( !nioe_pin ); // wait while nioe (*ss) pin is low/asserted } // this signal is negated by ncap sspcon = 0b00110100; // set: same but sspen now added } // initialize the picmicro i/o ports void init_pic_ports( void ) { // to avoid any glitches, set port states before setting direction porta = init_a_val; // initialize porta data latch portb = init_b_val; // initialize portb data latch portc = init_c_val; // initialize portc data latch // next instruction required for analog type parts // adcon1 = 0b00000111; // set porta for inputs trisa = tris_a_val; // initialize porta direction latch trisb = tris_b_val; // initialize portb direction latch trisc = tris_c_val; // initialize portc direction latch pie1 &= pie1_msk; // squelch spi based irq init_spi( 1 ); // 1 => await nioe deasserting } http://www..net/ datasheet pdf - http://www..net/
? 2000 microchip technology inc. preliminary ds00214a-page 41 AN214 /********************************************************************* * * * filename: stiminit.h * * date: 06/27/2000 * * revision: 1.4 * * * * tools: hi-tech pic c compiler v7.85 * * mplab 5.00.00 * * * * * * description: picmicro port and tris definitions * * * *********************************************************************/ extern uchar wrnackdone; #ifndef tris_a_val #define tris_a_val 0b00111111 #endif // port a: all inputs #ifndef init_a_val #define init_a_val 0b00000000 #endif #ifndef tris_b_val #define tris_b_val 0b11101001 #endif // port b: all outputs low #ifndef init_b_val #define init_b_val 0b00000000 #endif #ifndef tris_c_val #define tris_c_val 0b00011111 #endif // port c: nint and nack high #ifndef init_c_val #define init_c_val 0b11000000 #endif #define pie1_msk 0b11110111 /* squelches spi irq e.g. */ http://www..net/ datasheet pdf - http://www..net/
AN214 ds00214a-page 42 preliminary ? 2000 microchip technology inc. /********************************************************************* * * * the picmicro as an ieee 1451.2 compatible smart * * transducer interface module (stim) * * * ********************************************************************** * * * filename: stimteds.c * * date: 06/27/2000 * * revision: 1.3 * * * * contributor: richard l. fischer * * company: microchip technology inc. * * * * contributor: jeff burch * * company: agilent technologies * * * * * * tools: hi-tech pic c compiler v7.85 * * mplab 5.00.00 * * * ********************************************************************** * * * files required: * * * * stimteds.c * * * * pic.h (hi-tech file) * * common.h * * stimteds.h * * delays.h (hi-tech file) * * * ********************************************************************** * * * notes: * * * * description: common stim functions for accessing teds * * * *********************************************************************/ #include // processor if/def file #include ? common.h ? // project commons, etc. #include ? stimteds.h ? // #include ? c:\ht-pic\samples\delay.h ? extern uchar eeprom_data; // data for read/write ops. extern uchar ee_rd_wr_bit_cntr; // eeprom related constants - opcodes, w/start_bit #ifndef eeprom_bytes #define eeprom_bytes 2048 // x8 bit organization #endif #define len_of_global_ee_opcode 5 // utility for clocking up to one byte out the di line to the eeprom void send_ee_bits( uchar databits, uchar bitcount ) { // clock out on di the ? bitcount ? lsb ? s of ? databits ? http://www..net/ datasheet pdf - http://www..net/
? 2000 microchip technology inc. preliminary ds00214a-page 43 AN214 // note: 2mhz bit rate for vdd >= 4.5vdc // if using shift_left, must get first output bit left-justified if ( bitcount < 8 ) // careful: at least one caller uses > 8 databits <<= ( 8 - bitcount ) ; // loop dynamics based on 10mhz fosc; if changed nops may be required while ( bitcount-- ) { ee_di_pin = 0; // set data pin low databits <<= 1; // shift left 1 bit position if ( carry ) // test for carry { ee_di_pin = 1; // set data pin high } ee_sk_pin = 1; // tckh min = 300ns ee_sk_pin = 0; // tckl min = 200ns } } // these are a bit conservative w.r.t. setup/hold/speed ... uchar ee_read( unsigned int addr ) { // eeprom_data carries back the 8-bit payload // procedure: // di, sk are kept low between operations so they are low on entry here // assert cs // send start bit, 2 bits opcode // send 3 msb ? s of address (for 2048x8 organization) // send 8 lsb ? s of address // lower di // discard leading 0 startbit // read 8 bits of data // deassert cs ; sk is lowered by final bit send, di was lowered above ee_cs_pin = 1; // assert eeprom chip select // issue opcode send_ee_bits( ee_read_op, len_of_bytewise_ee_opcode ); // args: data,count // msb ? s of address -> 3 bits send_ee_bits( (uchar)(addr>>8), ee_addr_len-8 ); // args: data,count // lsb ? s of address -> 8 bits send_ee_bits( (uchar)addr, 8 ); ee_di_pin = 0; // set ee di to logic 0 // the discarding of a start bit is implicit; no extra sk edges // need be generated eeprom_data = 0x00; // byte to be returned ee_rd_wr_bit_cntr = 8; // init bit counter // procedure to read each data bit msb to lsb: // raise sk // wait >= tpd (400ns for microchip ? s 93c86) // sample ee_do pin, stuff/shift into appropriate capture bit // lower sk while ( ee_rd_wr_bit_cntr-- ) { ee_sk_pin = 1; // set clock pin high http://www..net/ datasheet pdf - http://www..net/
AN214 ds00214a-page 44 preliminary ? 2000 microchip technology inc. eeprom_data <<= 1; // shift composed byte by 1 // tpd provided inherently by prior instructions if ( ee_do_pin ) // test ee data out pin is high { eeprom_data |= 1; // ee_do is logic 1 so set lsb } ee_sk_pin = 0; // set clock pin low } ee_cs_pin = 0; // negate eeprom chip select return ( 0 ); // } uchar ee_write( unsigned int addr ) { // eeprom_data carries in the 8-bit payload // procedure: // di, sk are kept low between operations so they are low on entry here // assert cs // send start bit, 2 bits opcode // send 3 msb ? s of address (for 2048x8 organization) // send 8 lsb ? s of address // send 8 bits of data // wait out ? busy ? phase of eeprom (on do) // deassert cs & lower di; sk is lowered by final bit send ee_cs_pin = 1; // assert eeprom chip select // issue opcode send_ee_bits( ee_write_op, len_of_bytewise_ee_opcode ); // args: data,count // msb ? s of address -> 3 bits send_ee_bits( (uchar)(addr>>8), ee_addr_len-8 ); // args: data,count // lsb ? s of address -> 8 bits send_ee_bits( (uchar)addr, 8 ); // data bits send_ee_bits( eeprom_data, 8 ); // wait out ? busy ? ; complete ; on nioe up (ncap timeout e.g.) abort // a microchip 93c86 takes <= 10ms maximum, 4ms typical per word // microchip self-timed programming cycle is initiated on rising edge of // sk as the last data bit (do) is clocked out. // wait for ee done bit // rh 980803 - if frame is aborting, note it, but let ee finish, // allow ~30ms max or so here - 180us*166 for ( ee_rd_wr_bit_cntr =166; ee_rd_wr_bit_cntr; ee_rd_wr_bit_cntr-- ) { delayus( 180 ); // too much => eof latency suffers on aborted frame if ( ee_do_pin ) // test if ee device ready break; // byte completed // check for nioe deassertion, now or earlier this frame: frame_aborted(); // sets aborted_1451_io if nioe deasserts } // ee_di = ee_cs = 0 ; // note: cs hold after final sk drop can even be 0 ee_di_pin = 0; // compile trouble above ee_cs_pin = 0; // deassert eeprom chip select http://www..net/ datasheet pdf - http://www..net/
? 2000 microchip technology inc. preliminary ds00214a-page 45 AN214 return ( 0 ); } uchar ee_wr_enable( uchar opcode ) { // ee_wr_enable arg1: ee_ewen_op or ee_ewds_op (enable or disable) // di, sk are kept low between operations so they are low on entry here // first, assert cs, then // send: start bit, 2 bits opcode, 2 bits msb address, rest of dummy addr // finally, deassert cs & lower di; sk is lowered by final bit send ee_cs_pin = 1; // assert eeprom chip select send_ee_bits( opcode, len_of_global_ee_opcode ); send_ee_bits( 0, ee_addr_len-2 ); // these (~9) bits have don ? t care values; // therefore the 8 bit ? limit ? of // send_ee_bits() is ok // ee_di = ee_cs = 0 ; // note: cs hold after final sk drop can even be 0 ee_di_pin = 0; // compile trouble above ee_cs_pin = 0; return ( 0 ); } // ?? left off here ////////////////////////////////////////////////////////////////// // teds reading support ////////////////////////////////////////////////////////////////// // consult separate documentation regarding teds eeprom layout // to understand what follows void rd_teds_block( uchar blocknum ) { // it ? s assumed that 65536 is max teds block size // teds address calculating could be shared better between rd/wr... // get addr of ptr to 0th block ee_read( 1 ); // eeprom_data := msb teds_addr = eeprom_data; teds_addr <<= 8; ee_read( 0 ); // eeprom_data := lsb teds_addr += eeprom_data; // teds_addr has addr of ptr to 0th/1st teds block // below ccs went awry, so split expression teds_addr += blocknum; // teds_addr := addr of ptr to desired blk teds_addr += blocknum; // teds_addr := addr of ptr to desired blk ee_read( teds_addr+1 ); // msb teds_addr2 = eeprom_data; teds_addr2 <<= 8; ee_read( teds_addr ); // lsb teds_addr2 += eeprom_data; // teds_addr2 is now addr of desired block // send the block of teds. http://www..net/ datasheet pdf - http://www..net/
AN214 ds00214a-page 46 preliminary ? 2000 microchip technology inc. // serve bytes until ncap quits. // there are ~4 length bytes to start, and 2 checksum bytes at the end. // the length bytes don ? t count themselves but do count the checksum bytes. // the checksum accounts for the length bytes but not the cksum bytes. // i.e. we send start byte, some length bytes, and then n additional bytes, // where n is the value held in the length bytes for( ; ; ) { ee_read( teds_addr2++ ); // check for nioe deassertion, now or earlier this frame if ( frame_aborted() ) break; wr_1451_byte( eeprom_data ); } } ////////////////////////////////////////////////////////////////// // teds reading functions (global) // limited to 65536 bytes ////////////////////////////////////////////////////////////////// // read our prolog/catalog/directory at start of eeprom; // init. teds_format_vsn, teds_blks_per_chnl, num_channels void process_teds_prolog( void ) { // get supported chnl count from teds, to validate chnl_addr ? s later ee_read( 2 ); // fixed addr for chnl count num_channels = eeprom_data; if ( num_channels > max_num_channels || (!num_channels) ) num_channels = max_num_channels; // sanity check in case e^2 absent e.g. // get other metadata from teds - image format version, etc. // note: if addr of ptr block > 4 ; this prolog includes a vsn_no. // (before 970425, the hpl prolog lacked this) ee_read( 0 ); // low byte of addr of ptr blk teds_format_vsn = 1; // 1 here denotes assumption that e^2 holds a vsn_no teds_blks_per_chnl = 3; // until 970425 -- chnl,chnl_id,cal if ( eeprom_data <= 4 ) { ee_read( 1 ); // hi byte of addr of ptr blk if ( eeprom_data == 0 ) { // old-ish teds image; has no vsn_no; call it 0 teds_format_vsn = 0; } } if ( teds_format_vsn ) { ee_read( 4 ); // fixed addr for image format version teds_format_vsn = eeprom_data; // needn ? t keep around probably ee_read( 6 ); // should base addr on teds_format_vsn teds_blks_per_chnl = eeprom_data; } after_process_teds_prolog } // we ? re limited to 65kb teds below (eeproms for nsp3 are smaller) void rd_meta_teds( void ) { http://www..net/ datasheet pdf - http://www..net/
? 2000 microchip technology inc. preliminary ds00214a-page 47 AN214 rd_teds_block( 0 ); } void rd_meta_id_teds( void ) { rd_teds_block( 1 ); } void rd_full_teds_eeprom( void ) { // note: we cease reading bytes when eeprom capacity exhausted teds_addr2 = 0; while ( teds_addr2 < eeprom_bytes ) { ee_read( teds_addr2++ ); // check for nioe deassertion, now or earlier this frame if ( frame_aborted() ) break; wr_1451_byte( eeprom_data ); } } ////////////////////////////////////////////////////////////////// // teds reading functions (channel-specific) // limited to 65536 bytes ////////////////////////////////////////////////////////////////// void rd_channel_teds( void ) { rd_teds_block( 2+ ( chnl_addr-1 ) * teds_blks_per_chnl ); } void rd_channel_id_teds( void ) { rd_teds_block( 3+ ( chnl_addr-1 ) * teds_blks_per_chnl ); } void rd_calibration_teds( void ) { rd_teds_block( 4 + ( chnl_addr-1 ) * teds_blks_per_chnl ); } void rd_calibration_id_teds( void ) { if ( teds_blks_per_chnl >= 4 ) rd_teds_block( 5 + ( chnl_addr-1 ) * teds_blks_per_chnl ); } void wr_calibration_id_teds( void ) { // fixme: not implemented at this time post_inval_cmd( ); } ////////////////////////////////////////////////////////////////// // teds writing functions (global) ////////////////////////////////////////////////////////////////// http://www..net/ datasheet pdf - http://www..net/
AN214 ds00214a-page 48 preliminary ? 2000 microchip technology inc. void wr_full_teds_eeprom( void ) { // we expect host to wait ? write cal teds time ? between bytes // note: we cease reading and burning bytes when eeprom capacity exhausted // it ? s assumed that 65536 is max teds block size // check write_protect. // this macro should call post_inval_cmd( ) and return if the teds is // write protected check_write_protect ee_wr_enable( ee_ewen_op ); // write-enable the eeprom // accept and copy teds bytes to e^2 // we maybe should confirm checksum and size - no need, // ncap will read back and check teds_addr2 = 0; while ( teds_addr2 < eeprom_bytes ) { if ( frame_aborted() ) break; eeprom_data = rd_1451_byte(); // try to get next byte if ( aborted_1451_io ) break ; // don ? t write if no byte given ee_write( teds_addr2++ ); // this can take a while, e.g. 10ms } ee_wr_enable( ee_ewds_op ); // write-disable the eeprom // in case ted_format_vsn or num_channels etc. is affected process_teds_prolog(); // init e.g. teds_format_vsn, teds_blks_per_chnl } ////////////////////////////////////////////////////////////////// // teds writing functions (channel-specific) ////////////////////////////////////////////////////////////////// void wr_calibration_teds( void ) { // we expect host to wait ? write cal teds time ? between bytes // note: we cease reading and burning bytes when eeprom capacity exhausted // it ? s assumed that 65536 is max teds block size // write cal teds is not to be conditioned on jumper // // check write_protect jumper - if a4 is down, jumper is in, abort if ( !ra4 ) { post_inval_cmd(); return ; } // teds address calculating could be shared better between rd/wr... // get addr of ptr to 0th block ee_read( 1 ); // eeprom_data := msb teds_addr = eeprom_data; teds_addr <<= 8; ee_read( 0 ); // eeprom_data := lsb teds_addr += eeprom_data; // teds_addr has addr of ptr to 0th/1st teds block // below ccs went awry, so split expr. http://www..net/ datasheet pdf - http://www..net/
? 2000 microchip technology inc. preliminary ds00214a-page 49 AN214 teds_addr += 4; // teds_addr := addr of ptr to desired blk teds_addr += 4; // teds_addr := addr of ptr to desired blk ee_read( teds_addr+1 ); // msb teds_addr2 = eeprom_data; teds_addr2 <<= 8; ee_read( teds_addr ); // lsb teds_addr2 += eeprom_data; // teds_addr2 is now addr of desired block // proceed to accept and copy teds bytes to e^2 // there are ~4 length bytes to start, and 2 checksum bytes at the end. ee_wr_enable( ee_ewen_op ); // write-enable the eeprom while ( teds_addr2 < eeprom_bytes ) { if ( frame_aborted() ) break ; eeprom_data = rd_1451_byte(); // try to get next byte if ( aborted_1451_io ) break; // don ? t write if no byte sent ee_write( teds_addr2++ ); // this can take a while, e.g. 10ms } ee_wr_enable( ee_ewds_op ); // write-disable the eeprom } http://www..net/ datasheet pdf - http://www..net/
AN214 ds00214a-page 50 preliminary ? 2000 microchip technology inc. /********************************************************************* * * * filename: stimteds.h * * date: 06/27/2000 * * revision: 1.4 * * * * tools: hi-tech pic c compiler v7.85 * * mplab 5.00.00 * * * * * * description: variable/function references and picmicro pin * * definitions for communicating with teds. * * * *********************************************************************/ extern uchar frame_aborted( void ); extern unsigned int teds_addr; extern unsigned int teds_addr2; extern uchar num_channels; extern uchar teds_format_vsn; extern uchar teds_blks_per_chnl; extern uchar chnl_addr; extern uchar wr_1451_byte( uchar abyte ); extern uchar rd_1451_byte( void ); extern uchar frame_aborted( void ); extern uchar aborted_1451_io; extern void post_inval_cmd( void ); // eeprom related constants - pins; size #ifndef ee_cs_pin #define ee_cs_pin rb4 /* 93c86 pin 1 - chip select */ #endif #ifndef ee_sk_pin #define ee_sk_pin rb1 /* pin 2 - clock to eeprom */ #endif #ifndef ee_di_pin #define ee_di_pin rb2 /* pin 3 - data into eeprom */ #endif #ifndef ee_do_pin #define ee_do_pin rb3 /* pin 4 - data out of eeprom */ #endif // define this if the stim has write-protection circuitry for the teds #ifndef check_write_protect #define check_write_protect #endif // define this if you want to be called after the teds prolog is processed #ifndef after_process_teds_prolog #define after_process_teds_prolog http://www..net/ datasheet pdf - http://www..net/
? 2000 microchip technology inc. preliminary ds00214a-page 51 AN214 #endif #define ee_read_op 0b110 /* start_bit included in each of these */ #define ee_erase_op 0b111 #define ee_write_op 0b101 /* implicitly erases too */ #define len_of_bytewise_ee_opcode 3 #define ee_addr_len 11 /* org pin=0 i.e. ? by 8 ? eeprom orgnzn */ // next 4 distinguished by address ? s 2 msbits i.e. last 2 bits here #define ee_ewen_op 0b10011 /* start_bit included in each of these */ #define ee_ewds_op 0b10000 #define ee_eral_op 0b10010 #define ee_wral_op 0b10001 / http://www..net/ datasheet pdf - http://www..net/
AN214 ds00214a-page 52 preliminary ? 2000 microchip technology inc. /********************************************************************* * * * the picmicro as an ieee 1451.2 compatible smart * * transducer interface module (stim) * * * ********************************************************************** * * * filename: stimtemp.c * * date: 06/27/2000 * * revision: 1.8 * * * * contributor: richard l. fischer * * company: microchip technology inc. * * * * contributor: jeff burch * * company: agilent technologies * * * * * * tools: hi-tech pic c compiler v7.85 * * mplab 5.00.00 * * * ********************************************************************** * * * files required: * * * * stimtemp.c * * * * * * pic.h (hi-tech file) * * common.h * * stimtemp.h * * * ********************************************************************** * * * notes: * * * * description: template for developing new stim firmware * * * *********************************************************************/ #include // processor if/def file #include ? common.h ? #include ? stimtemp.h ? // this template illustrates recommended stim coding conventions. this code is // fully runable and implements a two channel loop-back stim. channel 1 is a // 16 bit actuator. channel 2 is a 16 bit sensor. when the device is triggered, // the cached actuator value is copied to the sensor data buffer. // === step 1:define how many channels are implemented on this stim === // note: this value is used to allocate memory for interrupt masks and status registers // the stim may have less channels than this as specified in the teds. see the // global variable num_channels; // #define max_num_channels 2; modify this define statement in the common.h file // === step 2: generate the stim version string with the ? generateversion ? tool === // stim version string // generated by generateversion stim_template_1.0 const uchar vsn_string[ 4 + 0x13 ] = { 0x00, 0x00, 0x00, 0x13, http://www..net/ datasheet pdf - http://www..net/
? 2000 microchip technology inc. preliminary ds00214a-page 53 AN214 ? s ? , ? t ? , ? i ? , ? m ? , ? _ ? , ? t ? , ? e ? , ? m ? , ? p ? , ? l ? , ? a ? , ? t ? , ? e ? , ? _ ? , ? 1 ? , ? . ? , ? 0 ? , 0xfa, 0x26, }; // === step 4: define the direction and initial values for each pic port === // port a: a5 inputnioe // a4 n/c // a3 n/c // a2 n/c // a1 n/c // a0 n/c #define tris_a_val 0b00111111 #define init_a_val 0b00000000 // port b: b7 n/c // b6 n/c // b5 n/c // b4 outputeepcsinitial value = 0 // b3 inputeepdout // b2 outputeepdininitial value = 0 // b1 outputeepdclkinitial value = 0 // b0 n/c #define tris_b_val 0b11101001 #define init_b_val 0b00000000 // port c: c7 outputnackinitial value = 1 // c6 outputnintinitial value = 1 // c5 outputdoutinitial value = 0 // c4 inputdin // c3 inputdclk // c2 inputntrig // c1 n/c // c0 n/c #define tris_c_val 0b00011111 #define init_c_val 0b11000000 // === step 5: define any macros to override default behaviors === // none in this case... // #define no_aux_status_registers; modify this define statement in the common.h file // === step 6: declare these required functions === void transducer_initialize(void); void transducer_trigger(void); void transducer_read(void); void transducer_write(void); // === step 7: implement the required functions === // this example supports a two channel stim. channel 1 is an actuator. // its value is ? looped back ? to the channel 2 sensor unsigned int channel1val; // uint 16 data model unsigned int channel2val; // uint 16 data model // --- initialize the transducer --- void transducer_initialize(void) { // this is called after the tri-state registers have been configured. // nothing to do in this example http://www..net/ datasheet pdf - http://www..net/
AN214 ds00214a-page 54 preliminary ? 2000 microchip technology inc. } // ----- perform the trigger and ack operation ---- void transducer_trigger( void ) { // here is where we need to act on some transducer, whether it be an adc or something else // perform trigger operation. in this example, // we loop back the actuator to the sensor channel2val = channel1val; standard_trigger( ); // call the generic trigger processing function } // ----- read the transducer -------- void transducer_read( void ) { // the ncap is reading data from the stim. use the wr_1451_byte( ) // function to send data out the 1451.2 interface switch ( chnl_addr ) { case 0: // channel 0 - read global transducer data wr_1451_byte(( uchar )( channel1val>>8 ));// high byte wr_1451_byte(( uchar )( channel1val ));// low byte wr_1451_byte(( uchar )( channel2val>>8 ));// high byte wr_1451_byte(( uchar )( channel2val ));// low byte break; case 1: // read channel 1 transducer data wr_1451_byte(( uchar )( channel1val>>8 ));// high byte wr_1451_byte(( uchar )( channel1val )); // low byte break; case 2: // read channel 2 transducer data wr_1451_byte(( uchar )( channel2val>>8 )); // high byte wr_1451_byte(( uchar )( channel2val )); // low byte break; default: // illegal command post_inval_cmd(); // function in stimdot2.c file break; // purpose: set stim invalid command bit } } // ----- write the transducer -------- void transducer_write( void ) { unsigned int dummy; // the ncap is writing data to the stim. use the rd_1451_byte( ) // function to read data from the 1451.2 interface switch ( chnl_addr ) { case 0: // channel 0 - write global transducer data channel1val = rd_1451_byte() << 8;// high byte, actuator write channel1val |= rd_1451_byte(); // low byte dummy = rd_1451_byte() << 8; // high byte, discard the sensor write dummy |= rd_1451_byte(); // low byte break; case 1: // channel 1 write (actuator) channel1val = rd_1451_byte() << 8; // high byte channel1val |= rd_1451_byte(); // low byte break; http://www..net/ datasheet pdf - http://www..net/
? 2000 microchip technology inc. preliminary ds00214a-page 55 AN214 default: // illegal command post_inval_cmd(); // function in stimdot2.c file break; // purpose: set stim invalid command bit } // note: we cache the value but don ? t transfer it to the loop back // sensor until we get the trigger. } http://www..net/ datasheet pdf - http://www..net/
AN214 ds00214a-page 56 preliminary ? 2000 microchip technology inc. /********************************************************************* * * * filename: stimtemp.h * * date: 06/27/2000 * * revision: 1.4 * * * * tools: hi-tech pic c compiler v7.85 * * mplab 5.00.00 * * * * notes: * * * * description: variable and function references for the * * template.c file * * * *********************************************************************/ /* reference linkage */ extern void standard_trigger( void ); extern void post_inval_cmd( void ); extern uchar wr_1451_byte( uchar abyte ); extern uchar rd_1451_byte( void ); extern uchar chnl_addr; http://www..net/ datasheet pdf - http://www..net/
? 2000 microchip technology inc. preliminary ds00214a-page 57 AN214 /********************************************************************* * * * the picmicro as an ieee 1451.2 compatible smart * * transducer interface module (stim) * * * ********************************************************************** * * * filename: stimcmd.c * * date: 06/27/2000 * * revision: 1.2 * * * * contributor: richard l. fischer * * company: microchip technology inc. * * * * contributor: jeff burch * * company: agilent technologies * * * * * * tools: hi-tech pic c compiler v7.85 * * mplab 5.00.00 * * * ********************************************************************** * * * files required: * * * * stimcmd.c * * * * common.h * * stimdot2.h * * stimcmd.h * * * ********************************************************************** * * * notes: * * * * description: this file is used to process the functional * * and channel address commands issued by the ncap * * over the 1451.2 interface. the functions * * called are located in the stimtemp.c, * * stimteds.c and stimdot2.c files. * * * *********************************************************************/ #include ? common.h ? #include ? stimdot2.h ? // #include ? stimcmd.h ? // // process the command void process_valid_cmd( void ) { switch ( func_addr ) // evaluate functional address { // this group of function codes are valid for both channel 0 and real channels case read_transducer_data: // read address 128 transducer_read( ); // function in stimtemp.c break; case write_transducer_data: // write address 0 transducer_write( ); // function in stimtemp.c break; //-> case write_control_cmd: // write address 1 wr_ctrl_cmd(); // function in stimdot2.c http://www..net/ datasheet pdf - http://www..net/
AN214 ds00214a-page 58 preliminary ? 2000 microchip technology inc. break; case read_status: // read address 130 rd_status(); // function in stimdot2.c break; case read_aux_status: // read address 132 rd_aux_status(); // function in stimdot2.c break; case read_int_mask: // read address 133 rd_int_mask(); // function in stimdot2.c break; case write_int_mask: // write address 5 wr_int_mask(); // function in stimdot2.c break; case read_aux_int_mask: // read address 134 rd_aux_int_mask(); // function in stimdot2.c break; case write_aux_int_mask: // write address 6 wr_aux_int_mask(); // function in stimdot2.c break; default: if ( chnl_addr ) // channel 1-255 function { // the following group of function codes are for real channels only switch ( func_addr ) { case read_teds: // read address 160 rd_channel_teds( ); // function in stimteds.c break; case read_id_teds: // read address 161 rd_channel_id_teds( ); // function in stimteds.c break; case write_calibration_teds: // write address 64 wr_calibration_teds( ); // function in stimteds.c break; case read_calibration_teds: // read address 192 rd_calibration_teds( ); // function in stimteds.c break; case read_calibration_id_teds: // read address 193 rd_calibration_id_teds( ); // function in stimteds.c break; case write_calibration_id_teds: // write address 65 wr_calibration_id_teds( ); // function in stimteds.c break; default: // allow user to provide additional functions default_1451dot2_function break; } } else // else global channel 0 { http://www..net/ datasheet pdf - http://www..net/
? 2000 microchip technology inc. preliminary ds00214a-page 59 AN214 // the following group of function codes are for channel 0 only switch ( func_addr ) { case read_triggered_channel_addr:// read address 131 rd_trig_chnl_addr(); // function in stimdot2.c break; case write_triggered_channel_addr:// write address 3 wr_trig_chnl_addr(); // function in stimdot2.c break; case read_fw_version: // read address 135 rd_fw_version(); // function in stimdot2.c break; case read_teds: // read address 160 rd_meta_teds(); // function in stimteds.c break; case read_id_teds: // read address 161 rd_meta_id_teds(); // function in stimteds.c break; case read_full_teds_eeprom: // read address 240 rd_full_teds_eeprom(); // function in stimteds.c break; case write_full_teds_eeprom: // read address 32 wr_full_teds_eeprom(); // function in stimteds.c break; default: // allow user to provide additional functions default_1451dot2_function // break; } } } after_1451dot2_frame while ( !frame_aborted() ) // wait until the ncap raises nioe { // if the ncap is still trying to read data, just clock out 0. // we stay here until the ncap is finished and raises nioe wr_1451_byte(0); // provides ? done ? handshake } } http://www..net/ datasheet pdf - http://www..net/
AN214 ds00214a-page 60 preliminary ? 2000 microchip technology inc. /********************************************************************* * * * filename: stimcmd.h * * date: 06/27/2000 * * * * tools: hi-tech pic c compiler v7.85 * * mplab 5.00.00 * * * * notes: * * * * description: reference linkage for variables and functions. * * * *********************************************************************/ /* the following declarations are reference linkage type */ extern uchar func_addr; // reference linkage extern uchar chnl_addr; // reference linkage /* reference linkage to stimteds.c file */ //extern void process_teds_prolog(); // init e.g. teds_format_vsn, teds_blks_per_chnl extern void rd_meta_teds( void ); extern void rd_meta_id_teds( void ); extern void rd_channel_teds( void ); extern void rd_channel_id_teds( void ); extern void rd_calibration_teds( void ); extern void rd_calibration_id_teds( void ); // extension read(s) extern void rd_fw_version( void ); extern void rd_full_teds_eeprom( void ); // teds write function(s) extern void wr_calibration_teds( void ); extern void wr_calibration_id_teds( void ); extern void wr_full_teds_eeprom( void ); //extern void transducer_initialize( void ); //extern void transducer_trigger( void ); extern void transducer_read( void ); extern void transducer_write( void ); /* 1451 byte i/o functions */ extern uchar wr_1451_byte( uchar abyte ); //extern uchar rd_1451_byte( void ); //extern void frame_complete( void ); //extern uchar frame_aborted( void ); // tests nioe and aborted_1451_io; sets latter // 1451 transducer, global functions extern void rd_status( void ); extern void rd_aux_status( void ); extern void rd_trig_chnl_addr( void ); extern void wr_trig_chnl_addr( void ); extern void rd_int_mask( void ); extern void wr_int_mask( void ); extern void rd_aux_int_mask( void ); extern void wr_aux_int_mask( void ); extern void wr_ctrl_cmd( void ); extern void post_inval_cmd( void ); http://www..net/ datasheet pdf - http://www..net/
? 2000 microchip technology inc. preliminary ds00214a-page 61 AN214 //extern void update_nint( void ); //extern void standard_trigger( void ); //extern void standard_reset( void ); //extern void init_mask_registers( void ); //extern void init_int_registers( void ); #ifndef after_1451dot2_frame #define after_1451dot2_frame #endif http://www..net/ datasheet pdf - http://www..net/
information contained in this publication regarding device applications and the like is intended through suggestion only and ma y be superseded by updates. it is your responsibility to ensure that your application meets with your specifications. no representation or warranty is give n and no liability is assumed by microchip technology incorporated with respect to the accuracy or use of such information, or infringement of patents or other intellectual property rights arising from such use or otherwise. use of microchip ? s products as critical components in life support systems is not authorized except with express written approval by microchip. no licenses are conveyed, implicitly or otherwise, except as maybe explicitly expressed herein, under an y intellectual property rights. the microchip logo and name are registered trademarks of microchip technology inc. in the u.s.a. and other countries. a ll rights reserved. all other trademarks mentioned herein are the property of their respective companies. ds00214a-page 62 preliminary ? 2000 microchip technology inc. all rights reserved. ? 2000 microchip technology incorporated. printed in the usa. 7/00 printed on recycled paper. americas corporate office microchip technology inc. 2355 west chandler blvd. chandler, az 85224-6199 tel: 480-786-7200 fax: 480-786-7277 technical support: 480-786-7627 web address: http://www.microchip.com atlanta microchip technology inc. 500 sugar mill road, suite 200b atlanta, ga 30350 tel: 770-640-0034 fax: 770-640-0307 boston microchip technology inc. 2 lan drive, suite 120 westford, ma 01886 tel: 508-480-9990 fax: 508-480-8575 chicago microchip technology inc. 333 pierce road, suite 180 itasca, il 60143 tel: 630-285-0071 fax: 630-285-0075 dallas microchip technology inc. 4570 westgrove drive, suite 160 addison, tx 75001 tel: 972-818-7423 fax: 972-818-2924 dayton microchip technology inc. two prestige place, suite 150 miamisburg, oh 45342 tel: 937-291-1654 fax: 937-291-9175 detroit microchip technology inc. tri-atria office building 32255 northwestern highway, suite 190 farmington hills, mi 48334 tel: 248-538-2250 fax: 248-538-2260 los angeles microchip technology inc. 18201 von karman, suite 1090 irvine, ca 92612 tel: 949-263-1888 fax: 949-263-1338 new york microchip technology inc. 150 motor parkway, suite 202 hauppauge, ny 11788 tel: 631-273-5305 fax: 631-273-5335 san jose microchip technology inc. 2107 north first street, suite 590 san jose, ca 95131 tel: 408-436-7950 fax: 408-436-7955 americas (continued) toronto microchip technology inc. 5925 airport road, suite 200 mississauga, ontario l4v 1w1, canada tel: 905-405-6279 fax: 905-405-6253 asia/pacific china - beijing microchip technology, beijing unit 915, 6 chaoyangmen bei dajie dong erhuan road, dongcheng district new china hong kong manhattan building beijing, 100027, p.r.c. tel: 86-10-85282100 fax: 86-10-85282104 china - shanghai microchip technology unit b701, far east international plaza, no. 317, xianxia road shanghai, 200051, p.r.c. tel: 86-21-6275-5700 fax: 86-21-6275-5060 hong kong microchip asia pacific unit 2101, tower 2 metroplaza 223 hing fong road kwai fong, n.t., hong kong tel: 852-2-401-1200 fax: 852-2-401-3431 india microchip technology inc. india liaison office no. 6, legacy, convent road bangalore, 560 025, india tel: 91-80-229-0061 fax: 91-80-229-0062 japan microchip technology intl. inc. benex s-1 6f 3-18-20, shinyokohama kohoku-ku, yokohama-shi kanagawa, 222-0033, japan tel: 81-45-471- 6166 fax: 81-45-471-6122 korea microchip technology korea 168-1, youngbo bldg. 3 floor samsung-dong, kangnam-ku seoul, korea tel: 82-2-554-7200 fax: 82-2-558-5934 asia/pacific (continued) singapore microchip technology singapore pte ltd. 200 middle road #07-02 prime centre singapore, 188980 tel: 65-334-8870 fax: 65-334-8850 taiwan microchip technology taiwan 10f-1c 207 tung hua north road taipei, taiwan tel: 886-2-2717-7175 fax: 886-2-2545-0139 europe denmark microchip technology denmark aps regus business centre lautrup hoj 1-3 ballerup dk-2750 denmark tel: 45 4420 9895 fax: 45 4420 9910 france arizona microchip technology sarl parc d ? activite du moulin de massy 43 rue du saule trapu batiment a - ler etage 91300 massy, france tel: 33-1-69-53-63-20 fax: 33-1-69-30-90-79 germany arizona microchip technology gmbh gustav-heinemann-ring 125 d-81739 m nchen, germany tel: 49-89-627-144 0 fax: 49-89-627-144-44 italy arizona microchip technology srl centro direzionale colleoni palazzo taurus 1 v. le colleoni 1 20041 agrate brianza milan, italy tel: 39-039-65791-1 fax: 39-039-6899883 united kingdom arizona microchip technology ltd. 505 eskdale road winnersh triangle wokingham berkshire, england rg41 5tu tel: 44 118 921 5858 fax: 44-118 921-5835 05/16/00 w orldwide s ales and s ervice microchip received qs-9000 quality system certification for its worldwide headquarters, design and wafer fabrication facilities in chandler and tempe, arizona in july 1999. the company?s quality system processes and procedures are qs-9000 compliant for its picmicro ? 8-bit mcus, k ee l oq ? code hopping devices, serial eeproms and microperipheral products. in addition, microchip ? s quality system for the design and manufacture of development systems is iso 9001 certified. http://www..net/ datasheet pdf - http://www..net/


▲Up To Search▲   

 
Price & Availability of AN214

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X